package edu.zut.main.thread;

public class ThreadSleep {
    public static void main(String[] args) {
        new Thread(new Countdown()).start();
    }

}
//利用sleep模拟倒计时
class Countdown implements Runnable{

    private int num = 10;

    @Override
    public void run() {
        while (true) {
            System.out.println(num--);
            try {
                //让当前线程休眠1s
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (num <= 0) {
                break;
            }
        }
    }
}
